﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Caching;
using Com.CMS263.Util;
namespace Com.CMS263.Caches
{
    public class MenuCache : CacheUtil
    {
       static string dpName = System.Web.HttpContext.Current.Server.MapPath("/manage/MenuText/menu.txt");

        public static void CacheMenu()
        {
            string menu = FileUtil.GetMenuText(dpName);
            CacheItemRemovedCallback remove = new CacheItemRemovedCallback(RemoveDataCallBack);
            Add(menu, "bkMenu", dpName);
        }
        public static void RemoveDataCallBack(string value, object data, CacheItemRemovedReason reason)
        {

            CacheMenu();
        }

        public static string GetMenu()
        {

            if (System.Web.HttpRuntime.Cache["bkMenu"] == null)
            {
                CacheMenu();
            }
            return System.Web.HttpRuntime.Cache["bkMenu"].ToString();
        }

    }
}
